import requests
from util.logger import logger

logger = logger('static/bilibili', name=__file__.split('/')[-1].split('.')[1])

headers = {
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36',

}
logger.info('开爬')
page = 1
while True:
    logger.info(f'page:{page}')
    url = f'https://api.bilibili.com/pgc/season/index/result?st=1&order=3&season_version=-1&spoken_language_type=-1&area=-1&is_finish=-1&copyright=-1&season_status=-1&season_month=-1&year=-1&style_id=-1&sort=0&page={page}&season_type=1&pagesize=20&type=1'
    response = requests.get(url, headers=headers)
    if response.status_code == 200:
        data = response.json()['data']
        has_next = data['has_next']
        items = data['list']
        for item in items:
            print(item)
        if has_next:
            page += 1
        else:
            break

logger.info('over..........')
